package com.example.leetcode.niuke;

import java.util.Scanner;

public class NiuKe5 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        String[] split = s.split(" ");
        if (split.length == 1) {
            System.out.println(0);
        }
        long sum = 1;
        long t = 1;
        for (int i = 0;i<split.length;i++) {
            sum *= Integer.parseInt(split[i]);
        }

        for (int i = 0;i<split.length -1;i++) {
            long l = sum / Integer.parseInt(split[i]);
            if (t * t == l) {
                System.out.println(i);
                return;
            }
            t *= Integer.parseInt(split[i]);
        }
        System.out.println(-1);
    }
}
